package com.template.entity;


import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.template.entity.content.Content;
import com.template.utlis.FeiShuMsgTypeEnum;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wangqi
 * @date 2024-01-08 16:52
 */
public class FeiShuPostContent extends FeiShuContent{
    private Post post;

    public FeiShuPostContent(FullTextMessage fullTextMessage) {
        super(FeiShuMsgTypeEnum.POST.getMsgType());
        Post post = new Post();
        post.setZhCn(new TitleContent(fullTextMessage));
        this.post = post;
    }

    public void setPost(Post post) {
        this.post = post;
    }
    public Post getPost() {
        return post;
    }
}

class Post {
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("zh_cn")
    private TitleContent zhCn;
    @JsonProperty("en_us")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private TitleContent enUs;

    public void setZhCn(TitleContent zhCn) {
        this.zhCn = zhCn;
    }

    public void setEnUs(TitleContent enUs) {
        this.enUs = enUs;
    }

    @JsonProperty("zh_cn")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public TitleContent getZhCn() {
        return zhCn;
    }

    @JsonProperty("en_us")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public TitleContent getEnUs() {
        return enUs;
    }

    public Post(TitleContent zhCn, TitleContent enUs) {
        this.zhCn = zhCn;
        this.enUs = enUs;
    }

    public Post() {
    }
}

class TitleContent {
    private String title;
    private List<List<Content>> content ;

    public String getTitle() {
        return title;
    }

    public List<List<Content>> getContent() {
        return content;
    }

    public TitleContent(FullTextMessage fullTextMessage) {
        this.title = fullTextMessage.getTitle();
        this.content =new  ArrayList<>();
        for (Paragraph paragraph : fullTextMessage.getParagraphList()) {
            List<Content> content = paragraph.getContent();
            this.content.add(content);
        }
    }
}
